home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Prg / SPLASH.ZIP / DEMO_CPP.CPP < prev    next >
C/C++ Source or Header  |  1997-09-14  |  5KB  |  167 lines

  1. #include "demo_cpp.h"
  2.  
  3. CTheApp ThisApp;
  4.  
  5. BOOL CTheApp::InitInstance()
  6. {
  7.     // Create main dialog box window and show m_strAPPTITLE in caption bar
  8.     m_pMainWnd = new CMainDlgWindow();
  9.     
  10.     if ( m_pMainWnd != NULL )
  11.     {
  12.         #ifdef _WIN32
  13.             m_pMainWnd->SetWindowText("SPLASH32.DLL Demo for C/C++");
  14.         #else
  15.             m_pMainWnd->SetWindowText("SPLASH16.DLL Demo for C/C++");
  16.         #endif
  17.         
  18.         // Set application (window) icon
  19.         #ifdef _WIN32
  20.             ::SetClassLong(m_pMainWnd->m_hWnd, GCL_HICON, (WORD)::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_APPLICATION)));
  21.         #else
  22.             SetClassWord(m_pMainWnd->m_hWnd, GCW_HICON, (WORD)LoadIcon(IDI_APPLICATION));
  23.         #endif
  24.     
  25.         return TRUE;
  26.     }
  27.     else
  28.         return FALSE;
  29. }
  30.  
  31. CMainDlgWindow::CMainDlgWindow()
  32. {
  33.     // We can use the help file path as a start for the default file
  34.     // Parse it to last backslash and add "SPLASH.BMP"
  35.     m_strSplashFileName = App.m_pszHelpFilePath;
  36.     m_strSplashFileName = m_strSplashFileName.Mid(0, m_strSplashFileName.ReverseFind('\\') + 1) + "SPLASH.BMP";
  37.     m_nHowLong = 1;
  38.     m_nWhichDLL = 0;
  39.  
  40.     //{{AFX_DATA_INIT(CMainDlgWindow)
  41.     //}}AFX_DATA_INIT
  42.     
  43.     // Create the Main Dialog Window
  44.     Create(IDD_MAIN);
  45. }
  46.  
  47. // ***** MESSAGE HANDLERS ******
  48.  
  49. BOOL CMainDlgWindow::OnCommand(WPARAM wParam, LPARAM lParam)
  50. {
  51.     // Handle messages before message map
  52.     // This is where we trap buton clicks to call DLL
  53.     // The button ID's for the AccuSoft functions are between 100 - 110
  54.     // Button ID 111 is used to show splash using normal bitmap loading techniques (No AccuSoft DLL's are needed)
  55.     
  56.     WORD wControl        = 0;
  57.     WORD wNotifyCode     = 0;
  58.  
  59.     #ifdef _WIN32
  60.         wControl =         LOWORD(wParam);
  61.         wNotifyCode =     HIWORD(wParam);
  62.     #else
  63.         wControl =         wParam;
  64.         wNotifyCode =    HIWORD(lParam);
  65.     #endif
  66.     
  67.     if ( wControl && wNotifyCode == BN_CLICKED )
  68.     {
  69.         // Call DDX routine to get data from screen into member vars
  70.         UpdateData(TRUE);
  71.         
  72.         // Subtract 100 from the control ID and call ShowSplashAnyFormat for values 0-10
  73.         // Call ShowSplashFromFile for 11 and ShowSplashFromResource for 12
  74.         // WIN32: ShowSplashAnyFormat() is NOT supported
  75.  
  76.         int nButton = wControl - 100;
  77.         
  78.         char* psz = m_strSplashFileName.GetBuffer(m_strSplashFileName.GetLength());
  79.         
  80.         #ifndef _WIN32
  81.             if ( nButton >= 0 && nButton <=10 )
  82.                 // This will show the splash screen using AccuSoft DLL(s). These DLL's are capable
  83.                 // of more than 16 color displays and can produce interesting visual effects.
  84.                 // Contact AccuSoft for more information.
  85.                 ShowSplashAnyFormat(psz, nButton, (m_nWhichDLL == 0 ) ? "ACCUSOFT.DLL" : "ACCU32IF.DLL", m_nHowLong);
  86.             else
  87.         #endif
  88.             
  89.         if ( nButton == 11 )
  90.             // This will show the splash screen by passing the name of a Windows bitmap (BMP)
  91.             // file. This routine currently supports up to 16 colors. No additional DLL's are
  92.             // needed.
  93.             ShowSplashFromFile(psz, m_nHowLong);
  94.         
  95.         else if ( nButton == 12 )
  96.             // This will show the splash screen by passing the name of a resource embedded in
  97.             // the calling program. This routine currently supports up to 16 colors. No additional
  98.             // DLL's are needed. This is not available to languages and applications that do not
  99.             // store their resources within their EXE or DLL. Sorry VB guys!
  100.             ShowSplashFromResource(AfxGetInstanceHandle(), "IDB_SPLASH", m_nHowLong);
  101.                 
  102.         m_strSplashFileName.ReleaseBuffer();
  103.     
  104.         // End the splash screen
  105.         EndSplash();
  106.     }    
  107.             
  108.     // Do default processing of this message
  109.     CWnd::OnCommand(wParam, lParam);
  110.     
  111.     return 1;
  112. }
  113.  
  114. void CMainDlgWindow::OnCancel()
  115. {
  116.     // Override default processing that closes window
  117. }
  118.  
  119. void CMainDlgWindow::OnClose()
  120. {
  121.     DestroyWindow();
  122. }
  123.  
  124. void CMainDlgWindow::PostNcDestroy()
  125. {
  126.     // Destroy this dialog box pointer
  127.     delete this;
  128.  
  129.     // Tell Windows to shut us down
  130.     ::PostQuitMessage(0);
  131. }
  132.  
  133. BOOL CMainDlgWindow::OnInitDialog()
  134. {
  135.     CDialog::OnInitDialog();
  136.     
  137.     // The ACCUSOFT DLL's are NOT supported under Win32. Gray these controls
  138.       #ifdef _WIN32
  139.         for ( UINT i = IDC_BUTTON0; i <= IDC_BUTTON10; i++ )
  140.             GetDlgItem(i)->EnableWindow(FALSE);
  141.  
  142.         GetDlgItem(IDC_RADIO1)->EnableWindow(FALSE);
  143.         GetDlgItem(IDC_RADIO2)->EnableWindow(FALSE);
  144.     #endif
  145.  
  146.       // Center this window on screen
  147.     CenterWindow();
  148.     
  149.     return TRUE;  // return TRUE  unless you set the focus to a control
  150. }
  151.  
  152. void CMainDlgWindow::DoDataExchange(CDataExchange* pDX)
  153. {
  154.     CDialog::DoDataExchange(pDX);
  155.     //{{AFX_DATA_MAP(CMainDlgWindow)
  156.     DDX_Text(pDX, IDC_EDIT1, m_strSplashFileName);
  157.     DDX_CBIndex(pDX, IDC_COMBO1, m_nHowLong);
  158.     DDX_Radio(pDX, IDC_RADIO1, m_nWhichDLL);
  159.     //}}AFX_DATA_MAP
  160. }
  161.  
  162. BEGIN_MESSAGE_MAP(CMainDlgWindow, CDialog)
  163.     //{{AFX_MSG_MAP(CMainDlgWindow)
  164.     ON_WM_CLOSE()
  165.     //}}AFX_MSG_MAP
  166. END_MESSAGE_MAP()
  167.